package peer.servertcp;

import peer.tools.ByteIntSwitch;
import peer.tools.ByteShortSwitch;

public class TunnelDataMessageTCP {
	byte[] data;
	int tunnelId;
	short messageType=MessageTCP.type_DataMessage;
	TunnelDataMessageTCP(byte[] data2,int tunnelId){
		data=new byte[6+data2.length];
		ByteIntSwitch.toByteArray(tunnelId, data, 0);
		ByteShortSwitch.toByteArray((short) data2.length, data, 4);
		System.arraycopy(data2, 0, data, 6, data2.length);
	}
	
	TunnelDataMessageTCP(byte[] data2){
		tunnelId=ByteIntSwitch.toInt(data2, 0);
		short len=ByteShortSwitch.toShort(data2, 4);
		data=new byte[len];
		System.arraycopy(data2, 6, data, 0, len);
	}
	
	public byte[] getData(){
		return data;
	}
	
	public int getTunnelId(){
		return tunnelId;
	}
	
	public short getMessageType(){
		return messageType;
	}
}
